# closer to Ceph is ideal

cmake_minimum_required(VERSION 3.10.2)
set(CMAKE_C_COMPILER gcc-11)
set(CMAKE_CXX_COMPILER g++-11)

project(cephfs-mds-rpmem-test
    LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)

include_directories(
    ${PROJECT_SOURCE_DIR}/src/include)

add_library(mock_Objecter
    ${PROJECT_SOURCE_DIR}/src/ceph_mock/Objecter.cc)


# debug use target
add_executable(test_nop EXCLUDE_FROM_ALL
    ${PROJECT_SOURCE_DIR}/src/debug_test_nop.cc
    ${PROJECT_SOURCE_DIR}/src/main_testing_frame.cc)

# every source in src/ starting with "test_" will be considered a test unit
file(GLOB test_target_srcs ${PROJECT_SOURCE_DIR}/src/test_*.cc)
message(DEBUG "got test program sources: ${test_target_srcs}")
foreach(src ${test_target_srcs})
    get_filename_component(tgt ${src} NAME_WLE)
    list(APPEND test_targets ${tgt})
    add_executable(${tgt}
        ${src}
        ${PROJECT_SOURCE_DIR}/src/main_testing_frame.cc
        ${PROJECT_SOURCE_DIR}/src/BenchmarkWorkloadBase.cc)
    target_link_libraries(${tgt}
        pthread
        mock_Objecter
        pmem pmemobj)
endforeach()
message("all test targets found: ${test_targets}")
